import { request } from 'umi';

/** 获取医嘱频次列表 */
export async function getFrequencyCodesList(
  params: {
    current?: number;
    pageSize?: number;
  }
) {
  return request(`/api/service/frequency/${params.current}/limt/${params.pageSize}`, {
    method: 'GET',
    params: {
      ...params
    },
    headers: {
      Action_Id: '800800000'
    }
  });
}

/** 获取医嘱频次列表 */
export async function getFrequencyCodesList1(
  params: {
    current?: number;
    pageSize?: number;
  }
) {
  return request(`/api/service/frequency/page/${params.current}/limt/${params.pageSize}`, {
    method: 'GET',
    params: {
      ...params
    },
  });
}

/**查询商城订单参数(800801000) */
export async function getOrderParams() {
  return request(`/api/service/order`, {
    method: 'GET',
    headers: {
      Action_Id: '800801000'
    }
  });
}

/**添加商城订单参数(800801001) */
export async function postOrderParams(data: PARAMSAPI.OrderParams) {
  return request(`/api/service/order`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '800801001'
    }
  });
}


/**查询商城退货退款原因列表(800802000) */
export async function getAftermentList(data: {
  current: number;
  pageSize: number;
  after_type?: string;
}) {
  return request(`/api/service/afterment/${data.current}/limit/${data.pageSize}`, {
    method: 'GET',
    params: {
      ...data
    },
    headers: {
      Action_Id: '800802000'
    }
  });
}

/**批量删除记录(800802003,800802006) */
export async function batchDelete(record_ids: string[], single?: boolean) {
  return request(`/api/service/afterment/batch/del`, {
    method: 'PATCH',
    data: {
      record_ids
    },
    headers: {
      Action_Id: single ? '800802006' : '800802003'
    }
  });
}

/** 添加退款/退货原因(800802001) */
export async function addReason(data: {
  after_type: string;
  is_use: string;
  reason: string;
  sort: number;
}) {
  return request(`/api/service/afterment`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '800802001'
    }
  });
}

/**编辑退款/退货原因(800802005 */
export async function updateReason(data: {
  record_id: string;
  after_type: string;
  is_use: string;
  reason: string;
  sort: number;
}) {
  return request(`/api/service/afterment/${data.record_id}`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '800802005'
    }
  });
}

/** 批量禁用/启用记录(800802002,800802004) */
export async function batchUpdateStatus(record_ids: string[], is_use: string, single?: boolean) {
  return request(`/api/service/afterment/batch/${is_use}/use`, {
    method: 'PATCH',
    data: {
      record_ids
    },
    headers: {  
      Action_Id: single ? '800802004' : '800802002'
    }
  });
}
